package com.itheima.web.controller;

import com.github.pagehelper.PageInfo;
import com.itheima.domain.Movies;
import com.itheima.service.MoviesService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/movies")
public class MoviesController {

    @Autowired
    MoviesService moviesService;

    @GetMapping("/findBye")
    public PageInfo<Movies> findByge(
            @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
            @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
            Integer cid, String keyword
    ) {
        return moviesService.findByPage(pageNum, pageSize, cid, keyword);
    }


// 这里要添加保存得有请求体时jason 格式

    @PostMapping("/save")
    public void save(@RequestBody Movies movies) {
        moviesService.save(movies);

    }

    @GetMapping("/findById")
    public Movies findById(Integer id){

     return moviesService.findById(id);
    }


    @DeleteMapping("/delete")
    public void delete(Integer id){

         moviesService.delete(id);
    }


    @DeleteMapping("/deleteBanTch")
    public void deleteBanTch(Integer[] ids){

        moviesService.deleteBanTch(ids);
    }

}

